var eventCenter = {}
var callbackFuncs = {}
var requestId = 0

eventCenter.notify = function(event,data){
    cc.systemEvent.emit(event, data)
}

eventCenter.request = function(path, data, func){

    if(cc.gamelogic[path]){
        
        if(func){
            callbackFuncs[requestId] = func
            data['requestId'] = requestId
            requestId = requestId + 1
        }

        cc.gamelogic[path](data)
    }   
}

eventCenter.respond = function(data){
    if(data.requestId && callbackFuncs[data.requestId]){
        callbackFuncs[data.requestId](data)
        callbackFuncs[data.requestId] = null
    }
}

module.exports = eventCenter